package com.wnhz.work.jy.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.nostra13.universalimageloader.core.ImageLoader;
import com.wnhz.work.jy.R;
import com.wnhz.work.jy.bean.TakeGoldBean;

import java.util.List;

/**
 * Created by Administrator on 2016/11/8 0008.
 */
public class TakeGoldAdapter extends BaseAdapter {
    private Context context;
    private List<TakeGoldBean> goodsInfo;

    public TakeGoldAdapter(Context context, List<TakeGoldBean> goodsInfo) {
        this.context = context;
        this.goodsInfo = goodsInfo;
    }

    @Override
    public int getCount() {
        return goodsInfo.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        TakeGoldViewHolder viewHolder = new TakeGoldViewHolder();
        if (convertView == null) {
            convertView = LayoutInflater.from(context).inflate(R.layout.order_item, null);
            viewHolder.iv_img = (ImageView) convertView.findViewById(R.id.iv_img);
            viewHolder.tv_title = (TextView) convertView.findViewById(R.id.tv_title);
            viewHolder.tv_numbers = (TextView) convertView.findViewById(R.id.tv_numbers);
            viewHolder.tv_money = (TextView) convertView.findViewById(R.id.tv_money);

            convertView.setTag(viewHolder);
        } else {
            viewHolder = (TakeGoldViewHolder) convertView.getTag();
        }

        ImageLoader.getInstance().displayImage(goodsInfo.get(position).getGoodsImg(), viewHolder.iv_img);
        viewHolder.tv_title.setText(goodsInfo.get(position).getGoodsName());
        viewHolder.tv_numbers.setText("x" + goodsInfo.get(position).getGoodsNums());
        viewHolder.tv_money.setText("¥ " + goodsInfo.get(position).getGoodsPrice());

        return convertView;
    }

    class TakeGoldViewHolder {
        ImageView iv_img;
        TextView tv_title;
        TextView tv_numbers;
        TextView tv_money;
    }
}
